<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,maximum-scale=1.0" />
    <title><#if entity.id??>编辑<#else>新增</#if>商品表</title>
    <#include "/view/admin/head.html"/>
    
        <script type="text/javascript" src="${base}/jstool/bootstrap-fileinput/js/fileinput.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-fileinput/js/locals/zh.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-fileinput/css/fileinput.min.css" />
    <script type="text/javascript" src="${base}/jstool/bootstrap-switch/bootstrap-switch.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-switch/bootstrap-switch.min.css" />
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css" />


    <script type="text/javascript" src="${base}/jstool/bootstrap-validator-0.5.3/js/bootstrapValidator.min.js"></script>
    <script type="text/javascript" src="${base}/jstool/bootstrap-validator-0.5.3/lang/zh_CN.min.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/jstool/bootstrap-validator-0.5.3/css/bootstrapValidator.min.css" />


    <style type="text/css">
        .list-path {
            height: 50px;
            line-height: 50px;
            background-color: #9acfea;
        }

        .table-class {
            width: 90%;
            text-align: center;
            border: 1px solid #afd9ee;
            margin: 0 auto;
            margin-top: 50px;
        }

        table th {
            width: 20%;
            background-color: #d9edf7;
            text-align: right;
        }

        table td {
            width: 20%;
            text-align: left;
        }


    </style>
    <script type="text/javascript">
    
    $(function(){
    	
      $('#picPath').fileinput({
    	  language: 'zh', //设置语言
          allowedFileExtensions : ['jpg', 'png','gif','jpeg'],//接收的文件后缀
          showUpload: true, //是否显示上传按钮
          uploadUrl: '${base}/busin/uploadImg?id=${entity.id!}&picType=0',//上传的地址
          showCaption: false,//是否显示标题
          browseClass: "btn btn-primary", //按钮样式
          maxFileCount: 10, //表示允许同时上传的最大文件个数
          previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
     
        
    }); 
      
      $('#picPath1').fileinput({
    	  language: 'zh', //设置语言
          allowedFileExtensions : ['jpg', 'png','gif','jpeg'],//接收的文件后缀
          showUpload: true, //是否显示上传按钮
          uploadUrl: '${base}/busin/uploadImg?id=${entity.id!}&picType=1',//上传的地址
          showCaption: false,//是否显示标题
          browseClass: "btn btn-primary", //按钮样式
          maxFileCount: 10, //表示允许同时上传的最大文件个数
          previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
     
        
    }); 
      $('#picPath2').fileinput({
    	  language: 'zh', //设置语言
          allowedFileExtensions : ['jpg', 'png','gif','jpeg'],//接收的文件后缀
          showUpload: true, //是否显示上传按钮
          uploadUrl: '${base}/busin/uploadImg?id=${entity.id!}&picType=3',//上传的地址
          showCaption: false,//是否显示标题
          browseClass: "btn btn-primary", //按钮样式
          maxFileCount: 10, //表示允许同时上传的最大文件个数
          previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
     
        
    }); 
      
    })
        $(function(){
            //初始化
		 $('[name="soldOutcb"]').bootstrapSwitch({
                                onText:"是",
                                offText:"否",
                        onColor:"success",
                        offColor:"info",
                        size:"small",
                        onSwitchChange:function(event,state){
                            if(state==true){
                                $(this).val("1");
                                $('[name="soldOut"]').val("1");
                            }else{
                                $(this).val("0");
                                $('[name="soldOut"]').val("0");
                            }
                        }
                    });

                $('#approveTime').datetimepicker();
                $('#createTime').datetimepicker();




            $('#czjcommodityForm').bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {





                    
                commodityName:{
                    message: '输入商品名称出错',
                    validators:{
                      /*   notEmpty: {
                            message: '商品名称不能为空'
                        }, */
                        stringLength:{
                            max: 255,
                            message: '商品名称不能超过 255个字符'
                        }
                    }
                }



                    ,
                presentPrice:{
                        message: '输入现价出错',
                        validators:{
                           /*  notEmpty: {
                                message: '现价不能为空'
                            }, */
                            stringLength:{
                                max: 11,
                                message: '现价不能超过 11个字符'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$|^[1-9][0-9]*\.[0-9]{1,2}$|^0\.[0-9]{1,2}$/,
                                message:'现价只能是金额'
                            }
                        }
                    }


                    ,
                originalPrice:{
                        message: '输入原价出错',
                        validators:{
                            /* notEmpty: {
                                message: '原价不能为空'
                            }, */
                            stringLength:{
                                max: 11,
                                message: '原价不能超过 11个字符'
                            },
                            regexp: {
                                regexp: /^[1-9][0-9]*$|^[1-9][0-9]*\.[0-9]{1,2}$|^0\.[0-9]{1,2}$/,
                                message:'原价只能是金额'
                            }
                        }
                    }


                    ,
                inventory:{
                    message: '输入库存数量出错',
                    validators:{
                        notEmpty: {
                            message: '库存数量不能为空'
                        },
                        stringLength:{
                            max: 11,
                            message: '库存数量不能超过 11个字符'
                        },
                        regexp: {
                            regexp: /^[0-9]+$/,
                                    message:'库存数量只能是数字'
                        }
                    }
                }

                    ,
                content:{
                    message: '输入内容出错',
                    validators:{
                       /*  notEmpty: {
                            message: '内容不能为空'
                        }, */
                        stringLength:{
                            max: 500,
                            message: '内容不能超过 500个字符'
                        }
                    }
                }

                    ,
                praiseCount:{
                    message: '输入获赞数出错',
                    validators:{
                        notEmpty: {
                            message: '获赞数不能为空'
                        },
                        stringLength:{
                            max: 11,
                            message: '获赞数不能超过 11个字符'
                        },
                        regexp: {
                            regexp: /^[0-9]+$/,
                                    message:'获赞数只能是数字'
                        }
                    }
                }

                    ,
                badCount:{
                    message: '输入差评数出错',
                    validators:{
                        notEmpty: {
                            message: '差评数不能为空'
                        },
                        stringLength:{
                            max: 11,
                            message: '差评数不能超过 11个字符'
                        },
                        regexp: {
                            regexp: /^[0-9]+$/,
                                    message:'差评数只能是数字'
                        }
                    }
                }

                    ,
                middleCount:{
                    message: '输入中评数出错',
                    validators:{
                        notEmpty: {
                            message: '中评数不能为空'
                        },
                        stringLength:{
                            max: 11,
                            message: '中评数不能超过 11个字符'
                        },
                        regexp: {
                            regexp: /^[0-9]+$/,
                                    message:'中评数只能是数字'
                        }
                    }
                }

                    ,
                highCount:{
                    message: '输入好评数出错',
                    validators:{
                        notEmpty: {
                            message: '好评数不能为空'
                        },
                        stringLength:{
                            max: 11,
                            message: '好评数不能超过 11个字符'
                        },
                        regexp: {
                            regexp: /^[0-9]+$/,
                                    message:'好评数只能是数字'
                        }
                    }
                }

                    ,
                allCount:{
                    message: '输入总评论数出错',
                    validators:{
                        notEmpty: {
                            message: '总评论数不能为空'
                        },
                        stringLength:{
                            max: 11,
                            message: '总评论数不能超过 11个字符'
                        },
                        regexp: {
                            regexp: /^[0-9]+$/,
                                    message:'总评论数只能是数字'
                        }
                    }
                }










                }
            });


        });

    
    function doSvse(){
    	
    	var typeId=$("#typeId").val();
    	
    	if(typeId==-1){
    		alert("请选择商品类型，商品类型不能为空");
    		return ;
    	}
    	
    	document.form1.submit();
    	return ;
    }
    </script>
</head>
<body>

	<#include "/view/admin/listnav.html"/> 


<div class="table-class">
    <#include "/view/admin/opermsg.html"/>
    <form id="czjcommodityForm" action="${base}/busin/save" id="form1" name="form1"
     >
    <table class="table table-bordered">

                        <input type="hidden" style="display: none" name="id" value="${entity.id!}"/>
						 <input type="hidden"  name="businessId" value="${businessId!}"/>
             
                <th>商品名称</th>
                <td>
                    <div class="form-group">
                        <input type="text" class="form-control" id="commodityName" name="commodityName" placeholder="请输入商品名称" value="${entity.commodityName!}">
                    </div>
                </td>
      <th>商品类型</th>
                <td>
                  <div class="form-group">
                        <select id="typeId" name="typeId"
                                class="form-control selectpicker"   data-live-search="true"
                        >
                       			  <option value="-1">--请选择商品类型--</option>
                                    <#list listTypeId as lv>
                                        <option value="${lv.value!}"
                                        <#if lv.value??&&entity.typeId??&&entity.typeId == lv.value >
                                            selected="selected"
                                        </#if>
                                            >${lv.name!}</option>
                                    </#list>

                        </select>
                    </div>
                </td>
                
               
                </tr>

                <tr>
                   <th>原价(元)</th>
                <td>
                    <div class="form-group">
                        <input type="text" class="form-control" id="originalPrice" name="originalPrice" placeholder="请输入原价" value="${entity.originalPrice!}">
                    </div>
                </td>
                 <th>现价(元)</th>
                <td>
                    <div class="form-group">
                        <input type="text" class="form-control" id="presentPrice" name="presentPrice" placeholder="请输入现价" value="${entity.presentPrice!}">
                    </div>
                </td>
             
                </tr>
    <#--    <tr>
            <th>库存数量</th>
            <td>
                <div class="form-group">
                    <input type="text" class="form-control" id="inventory" name="inventory" placeholder="请输入库存量" value="${entity.inventory!}">
                </div>
            </td>
            <th></th>
            <td>

            </td>

        </tr>-->
                
                <tr>
                <th>描述</th>
                <td colspan="3">
                    <div class="form-group">
                        <!-- <input type="text" class="form-control" id="content" name="content" placeholder="请输入内容" value="${entity.content!}"> -->
                        <textarea class="form-control" rows="5" name="content" placeholder="请输入描述">${entity.content!}</textarea>
                    </div>
                </td>
                </td>
                </tr>
             

  <tr>
            <td colspan="4" width="100%" style="text-align: center;">
                 <input type="button" onclick="doSvse()" class="btn btn-success " value="下一步"/>

            </td>
        </tr>
    </table>
</form>




</div>

<script type="text/javascript">

function doDelete(imgId,id){
	
		if(""==imgId){
			alert("不能删除图片，服务器开小差了");
			
			return ;
		}
		if(""==id){
			alert("不能删除图片，服务器开小差了");
			return ;
		}
		 $
		.ajax( {
			url : "${base}/busin/delteImg",
			data : {
				"imgId" :imgId,
				"id":id
			},
			dataType : "json",
			type : "get",
			success : function(data) {
				if(data.status==0){
					alert("服务器错误");
				}else{
					
					window.location="${base}/busin/add?id="+id;
					
				}
			},
			error : function() {
				alert("服务器错误,服务器开小差了。。");
			}

		});
		
	} 

</script>


</body>
</html>
